#include <bits/stdc++.h>
using namespace std;

const int N=5e5+50;
long long n,m,len,v,v0[N],a[N],d[N],p[N],t,ans,cnt,tot;
long long l,r,mid;
bool ok(long long x,long long i){//will the i th car be examined by the xth point?
    return v0[i]*v0[i]+2*a[i]*(p[x]-d[i])>v*v;
}
struct node{
    long long l,r;
};

bool cmp(node x,node y){
    if(x.r==y.r)return x.l>y.l;
    return x.r<y.r;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        node s[N];
        memset(a,0,sizeof a);
        memset(v0,0,sizeof v0);
        memset(d,0,sizeof d);
        memset(p,0,sizeof p);
        cnt=0,ans=0,tot=0;
        cin>>n>>m>>len>>v;
        int f=0;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v0[i]>>a[i];
            if(a[i]!=0)f=1;
        }
        for(int i=1;i<=m;i++) cin>>p[i];
        if(f==0){//
            for(int i=1;i<=n;i++){
                if(v0[i]>v&&d[i]<=p[m])cnt++;
            }
            cout<<cnt<<' ';
            if(cnt!=0)cout<<m-1<<'\n';
            else cout<<m<<'\n';
            continue;
        }
        for(int i=1;i<=n;i++){
            l=(lower_bound(p+1,p+n+1,d[i])-p),r=m;
            //cout<<l<<' ';
            if(a[i]>=0){
                if(!ok(m,i)){
                    cnt++;
                    continue;
                }
                s[++tot].r=m;
                while(l<=r){
                    mid=(l+r)>>1;
                    if(ok(mid,i))r=mid-1;
                    else l=mid+1;
                }
                if(!ok(l,i))l++;
                s[tot].l=l;
            }
            else{
                if(!ok(l,i)){
                    cnt++;
                    continue;
                }
                s[++tot].l=l;
                while(l<=r){
                    mid=(l+r)>>1;
                    if(ok(mid,i))l=mid+1;
                    else r=mid-1;
                }
                if(!ok(l,i)||l>m)l--;
                s[tot].r=l;
            }
        }
        cout<<n-cnt<<' ';
        /*cout<<'\n';
        for(int j=1;j<=tot;j++){
            cout<<s[j].l<<' '<<s[j].r<<'\n';
        }*/
        sort(s+1,s+1+tot,cmp);
        int precut=0;
        for(int i=1;i<=tot;i++){
            if(s[i].l<=precut)continue;
            precut=s[i].r;
            ans++;
        }
        cout<<m-ans<<'\n';
    }

    return 0;
}
/*
1
10 10 150307 247
62978 968 -5
51700 883 -3
40408 564 -1
60366 870 -41
35943 797 -7
47476 595 -11
59020 672 -10
81024 964 -11
80637 695 -5
66114 874 -1
46720 48066 57373 60882 68842 72773 82820 116695 122159 150307
*/
//10 7




